package com.halixun.d2app.adapter.holder;

import android.app.Activity;
import android.graphics.Rect;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.halixun.d2app.R;
import com.halixun.d2app.adapter.MyFootsAdapter;
import com.halixun.d2app.base.BaseViewHolder;
import com.halixun.d2app.bean.OrderListInfo;
import com.halixun.d2app.ui.ImageLookActivity;
import com.halixun.d2app.utils.GlideOptions;
import com.halixun.d2app.view.GlideRoundTransform;
import com.previewlibrary.GPreviewBuilder;
import com.previewlibrary.enitity.ThumbViewInfo;

import java.util.ArrayList;

/**
 * @ProjectName: D2App
 * @Package: com.halixun.d2app.adapter.holder
 * @ClassName: MyFootsViewHolder
 * @Description: java类作用描述
 * @Author: hdx
 * @CreateDate: 2019/11/29 9:43
 * @UpdateUser: hdx
 * @UpdateDate: 2019/11/29 9:43
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class MyFootsViewHolder extends BaseViewHolder<OrderListInfo> {

    private TextView title;

    private TextView price;

    private OrderListInfo data;

    private MyFootsAdapter.MyFootsAdapterListener listener;

    public MyFootsViewHolder(View itemView) {
        super(itemView);
        initView();
        setListeners();
    }

    public MyFootsViewHolder(View itemView, MyFootsAdapter.MyFootsAdapterListener listener) {
        this(itemView);
        this.listener = listener;
    }

    private void setListeners() {
        itemView.setOnClickListener(v->{
            if (null!=listener){
                listener.onFootsClickListener(getAdapterPosition());
            }
        });
//        itemView.setOnLongClickListener(v -> {
//            ArrayList<ThumbViewInfo> mThumbViewInfoList = new ArrayList<>();
//            mThumbViewInfoList.clear();
//            Rect bounds = new Rect();
//            image.getGlobalVisibleRect(bounds);
//            ThumbViewInfo item = new ThumbViewInfo(data.getPic());
//            item.setBounds(bounds);
//            mThumbViewInfoList.add(item);
//            GPreviewBuilder.from((Activity) mContext)
//                    //是否使用自定义预览界面，当然8.0之后因为配置问题，必须要使用
//                    .to(ImageLookActivity.class)
//                    .setData(mThumbViewInfoList)
//                    .setCurrentIndex(0)
//                    .setSingleFling(true)
//                    .setType(GPreviewBuilder.IndicatorType.Number)
//                    // 小圆点
////  .setType(GPreviewBuilder.IndicatorType.Dot)
//                    .start();//启动
//            return true;
//        });
    }

    private void initView() {
        title = itemView.findViewById(R.id.title);
        price = itemView.findViewById(R.id.price);
    }

    @Override
    public void setLayoutInfo(OrderListInfo info) {
        this.data = info;
        title.setText(info.getTitle());
        price.setText("￥"+info.getPrice());
    }
}
